home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_386 / xlispstat / src2.lzh / XLisp-Stat / windows.c < prev    next >
C/C++ Source or Header  |  1990-10-02  |  5KB  |  176 lines

  1. /* windows - general window functions                                  */
  2. /* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
  3. /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
  4. /* You may give out copies of this software; for conditions see the    */
  5. /* file COPYING included with this distribution.                       */
  6.  
  7. #include "xlisp.h"
  8. #include "osdef.h"
  9. #ifdef ANSI
  10. #include "xlproto.h"
  11. #include "xlsproto.h"
  12. #include "iviewproto.h"
  13. #include "Stproto.h"
  14. #else
  15. #include "xlfun.h"
  16. #include "xlsfun.h"
  17. #include "iviewfun.h"
  18. #include "Stfun.h"
  19. #endif ANSI
  20. #include "xlvar.h"
  21. #include "xlsvar.h"
  22.  
  23. /* forward declarations */
  24. #ifdef ANSI
  25. LVAL window_dimensions(int,int);
  26. #else
  27. LVAL window_dimensions();
  28. #endif ANSI
  29.  
  30. /**************************************************************************/
  31. /**                                                                      **/
  32. /**                           Utility Functions                          **/
  33. /**                                                                      **/
  34. /**************************************************************************/
  35.  
  36. void get_window_bounds(object, left, top, width, height)
  37.     LVAL object;
  38.     int *left, *top, *width, *height;
  39. {
  40.   LVAL size, location;
  41.   
  42.   size = slot_value(object, s_size);
  43.   location = slot_value(object, s_location);
  44.   if (consp(size) && fixp(car(size)) && consp(cdr(size)) && fixp(car(cdr(size)))) {
  45.     *width = getfixnum(car(size));
  46.     *height = getfixnum(car(cdr(size)));
  47.   }
  48.   if (consp(location) && fixp(car(location)) 
  49.       && consp(cdr(location)) && fixp(car(cdr(location)))) {
  50.     *left = getfixnum(car(location));
  51.     *top = getfixnum(car(cdr(location)));
  52.   }
  53. }
  54.  
  55. /***********************************************************************/
  56. /**                                                                   **/
  57. /**                  General Window Methods Functions                 **/
  58. /**                                                                   **/
  59. /***********************************************************************/
  60.  
  61. LVAL xsshowwindow()
  62. {
  63.   LVAL object = xlgaobject();
  64.   IVIEW_WINDOW w = GETWINDOWADDRESS(object);
  65.   
  66.   if (w == nil) {
  67.     send_message(object, sk_allocate);
  68.     w = GETWINDOWADDRESS(object);
  69.   }
  70.   StShowWindow(w);
  71.   return(NIL);
  72. }
  73.  
  74. LVAL xshidewindow()
  75. {
  76.   LVAL object = xlgaobject();
  77.   IVIEW_WINDOW w = GETWINDOWADDRESS(object);
  78.   
  79.   if (w != nil) StHideWindow(w);
  80.   return(NIL);
  81. }
  82.  
  83. LVAL xswindow_title()
  84. {
  85.   IVIEW_WINDOW w;
  86.   LVAL object, title;
  87.   char *str;
  88.   
  89.   object = xlgaobject();
  90.   w = GETWINDOWADDRESS(object);
  91.   if (moreargs()) {
  92.     title = xlgastring();
  93.     set_slot_value(object, s_title, title);
  94.     if (w != nil) {
  95.       str = (char *) getstring(title);
  96.       StWSetTitle(w, str);
  97.     }
  98.   }
  99.   return(slot_value(object, s_title));
  100. }
  101.   
  102. static LVAL window_dimensions(which, frame)
  103.     int which, frame;
  104. {
  105.   LVAL object, slot;
  106.   IVIEW_WINDOW w;
  107.   int a, b, set = FALSE;
  108.   
  109.   object = xlgaobject();
  110.   if (moreargs()) {
  111.     set = TRUE;
  112.     a = getfixnum(xlgafixnum());
  113.     b = getfixnum(xlgafixnum());
  114.   }
  115.   xllastarg();
  116.   
  117.   w = GETWINDOWADDRESS(object);
  118.   slot = (which == 'L') ? s_location : s_size;
  119.   
  120.   if (set) {
  121.     if (! frame) set_slot_value(object, slot, integer_list_2(a, b));
  122.     if (w != nil) {
  123.       switch (which) {
  124.       case 'L': StWSetLocation(w, a, b, frame); break;
  125.       case 'S': StWSetSize(w, a, b, frame);     break;
  126.       }
  127.     }
  128.   }
  129.   if (w != nil) {
  130.     switch (which) {
  131.     case 'L': 
  132.       StWGetLocation(w, &a, &b, FALSE);
  133.       set_slot_value(object, slot, integer_list_2(a, b));
  134.       if (frame) StWGetLocation(w, &a, &b, TRUE);
  135.       break;
  136.     case 'S': 
  137.       StWGetSize(w, &a, &b, FALSE);
  138.       set_slot_value(object, slot, integer_list_2(a, b));
  139.       if (frame) StWGetSize(w, &a, &b, TRUE);
  140.       break;
  141.     }
  142.     return(integer_list_2(a, b));
  143.   }
  144.   else return(slot_value(object, slot));
  145. }
  146.  
  147. LVAL xswindow_location()       { return(window_dimensions('L', FALSE)); }
  148. LVAL xswindow_size()           { return(window_dimensions('S', FALSE)); }
  149. LVAL xswindow_frame_location() { return(window_dimensions('L', TRUE));  }
  150. LVAL xswindow_frame_size()     { return(window_dimensions('S', TRUE));  }
  151.  
  152. /**************************************************************************/
  153. /**                                                                      **/
  154. /**                         Screen Info Functions                        **/
  155. /**                                                                      **/
  156. /**************************************************************************/
  157.  
  158. LVAL xsscreen_size()
  159. {
  160.   int width, height;
  161.  
  162.   StGetScreenSize(&width, &height);
  163.   return(integer_list_2(width, height));
  164. }
  165.  
  166. LVAL xsscreen_has_color()
  167. {
  168.   return((StScreenHasColor()) ? s_true : NIL);
  169. }
  170.  
  171. LVAL xsflush_graphics()
  172. {
  173.   StFlushGraphics();
  174.   return(NIL);
  175. }
  176.